<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <#include "/common/plateform/include/common-base.ftl">
    <title>管理控制台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
</head>
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">
    <!-- top start -->
    <#include "/common/plateform/top.ftl">
    <!-- top end -->

    <!-- left start -->
    <#include "/common/plateform/left-project.ftl">
    <!-- left end-->


    <div class="content-wrapper">
        <div class="row">
            <!-- Main content -->
            <section class="content">
                <!-- Small boxes (Stat box) -->
                <div class="col-lg-12">
                    <div class="callout">
                        <h4>管理控制台 - <a style="color:#ff9f00" href="javascript:" onclick="toManagementBack()"><span id="tital_sys_name"></span></a></h4>
                        <p class="lh20 pt10 f12">说明：该管理控制台主要是针对项目工程的管控，并非业务管理、运营后台，不提供任何业务操作功能。</p>
                    </div>
                </div>
                <div class="col-lg-9">
                    <div class="box box-solid">
                        <div class="box-header with-border"><h3 class="box-title">数据统计</h3>
                        </div>
                        <div class="box-body">
                            <div class="form-group col-lg-12" id="statis-info"
                                 style="height:340px;border:1px #f0f0f0 solid;">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-3">
                    <div class="box box-solid">
                        <div class="box-header with-border"><h3 class="box-title">常用功能</h3>
                        </div>
                        <div class="box-body">
                            <div class="pad box-pane-right" style="min-height:180px">
                                <div class="description-block margin-bottom" data-step="1" data-intro="数据库表设计、字段设计。" data-position='left'>
                                    <a class="text-green" data-pjax="true" href="javascript:" onclick="toMenuUrl('objName-table')">
                                        <div class="sparkbar pad">
                                            <i class="fa fa-database f32"></i>
                                        </div>
                                        <h5 class="description-header fb">数据库设计</h5>
                                        <span class="description-text text-black">表设计、字段设计</span>
                                    </a>
                                </div>
                                <div class="description-block margin-bottom" data-step="2" data-intro="菜单模块设置、表单设计制作。" data-position='left'>
                                    <a class="text-red" data-pjax="true" href="javascript:" onclick="toMenuUrl('sysModule-list')">
                                        <div class="sparkbar pad">
                                            <i class="fa fa-sitemap f32"></i>
                                        </div>
                                        <h5 class="description-header fb">模块管理</h5>
                                        <span class="description-text text-black">菜单模块、表单制作</span>
                                    </a>
                                </div>
                                <div class="description-block" data-step="3" data-intro="接口配置、接口参数。" data-position='left'>
                                    <a class="text-primary" data-pjax="true" href="javascript:" onclick="toMenuUrl('sysParamManager-list')">
                                        <div class="sparkbar pad">
                                            <i class="fa fa-share-alt f32"></i>
                                        </div>
                                        <h5 class="description-header fb">接口管理</h5>
                                        <span class="description-text text-black">接口配置、接口参数</span>
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-12" id="home-user-tips" style="display: none;">
                    <div class="callout callout-danger">
                        <h4>警告!</h4>
                        <p>请尽快添加本项目工程的管理员账号！<a href="${page_admin}/project/user-list">去添加</a></p>
                    </div>
                </div>
                <div class="col-lg-12" id="home-user-not-onLine" style="display: none;">
                    <div class="callout callout-warning">
                        <h4>提示!</h4>
                        <p>您的当前环境是离线互联网环境！</p>
                    </div>
                </div>
            </section>
        </div>
    </div>

    <!-- foot start -->
    <#include "/common/plateform/foot.ftl">
    <!-- foot start -->

</div>

</body>
</html>

<script>
    var clickMenu = 'plateForm-index';
    var localStorSe = strUtil.getLocalStorage("sysEname");
    var defSysEname = strUtil.doNull(localStorSe, "");

    //判断用户浏览器是否上互联网
    var onLine = window.navigator.onLine;
    if(!onLine){
        $('#home-user-not-onLine').show();
        strUtil.setLocalStorage("current_online",'F');
    }else{
        strUtil.setLocalStorage("current_online",'T');
    }

    if(strUtil.isNull(localStorSe)){
        defSysEname = $.base64.decode(strUtil.getQueryString("se"));
        strUtil.setLocalStorage("sysEname",defSysEname);
    }
    $("#tital_sys_name").html(defSysEname);


    //加载js文件
    $.getScript("${ctx}/common/plateform/base/echarts/echarts.min.js", function () {

        var index_load = layer.msg("数据正在统计中...");

        //showManagerUserTips();

        var dataP = {"pageName": "plateform-console", "formName":"searchForm","searchSysEname":defSysEname};
        $.getJSON(common_list_url, dataP, function (myData) {
            console.log('DataStatistics',myData);
            if(myData.total>0){
                var obj = myData.rows[0];
                var infoObj = [
                    "数据",
                    "statis-info",
                    ['服务接口', '数据表','功能模块', '接口', '插件', '数据字典','管理员'],
                    [obj.rpcServerCount,obj.sortInfoCount, obj.sysModuleCount, obj.paramManagerCount, obj.pluginManagerCount, obj.dataCateCount,obj.uctUserSysCount]
                ];
                var infoChart = echarts.init(document.getElementById(infoObj[1]));
                var infoOption = getOptionZhu(infoObj);
                infoChart.setOption(infoOption);//完成初始化加载
            }
        });

        checkInitDataSource();

        /*** 0、数据统计 start
        var data1 = getModuleCount();
        var data2 = getDataTaleCount();
        var data3 = getParamCount();
        var data4 = getPluginCount();
        var data5 = getSysDictCount();
        var data6 = getSysUserCount();
        var infoObj = [
            "数据统计",
            "statis-info",
            ['功能模块', '数据表', '接口', '插件', '数据字典','管理员'],
            [data1, data2, data3, data4, data5,data6]
        ];
        var infoChart = echarts.init(document.getElementById(infoObj[1]));
        var infoOption = getOptionZhu(infoObj);
        infoChart.setOption(infoOption);//完成初始化加载

         ***/

        layer.close(index_load);

    });

    function getDataTaleCount() {
        var count = 0;
        $.ajaxSettings.async = false;
        var dataP = {"modelTypes": "s_sortInfo", "sortInfo.w_sysName": defSysEname};
        $.getJSON(common_list_url, dataP, function (myData) {
            count = myData.total;
        });
        return count;
    }

    function getModuleCount() {
        var count = 0;
        $.ajaxSettings.async = false;
        var dataP = {"modelTypes": "s_sysModule", "sysModule.w_sysName": defSysEname};
        $.getJSON(common_list_url, dataP, function (myData) {
            count = myData.total;
        });
        return count;
    }

    function getParamCount() {
        var count = 0;
        $.ajaxSettings.async = false;
        var dataP = {"modelTypes": "s_sysParamManager", "sysParamManager.w_sysName": defSysEname};
        $.getJSON(common_list_url, dataP, function (myData) {
            count = myData.total;
        });
        return count;
    }

    function getPluginCount() {
        var count = 0;
        $.ajaxSettings.async = false;
        var dataP = {"modelTypes": "s_sysPluginManager", "sysPluginManager.w_sysName": defSysEname};
        $.getJSON(common_list_url, dataP, function (myData) {
            count = myData.total;
        });
        return count;
    }

    function getRulesCount() {
        var count = 0;
        $.ajaxSettings.async = false;
        var dataP = {"modelTypes": "s_sysRulesProd", "sysRulesProd.w_sysName": defSysEname};
        $.getJSON(common_list_url, dataP, function (myData) {
            count = myData.total;
        });
        return count;
    }


    function getSysDictCount() {
        var count = 0;
        $.ajaxSettings.async = false;
        var dataP = {"doCode": "dictCateList", "sysEname": defSysEname};
        $.getJSON(common_list_url, dataP, function (myData) {
            count = myData.total;
        });
        return count;
    }

    function getSysUserCount() {
        var count = 0;
        $.ajaxSettings.async = false;
        var dataP = {"modelTypes": "s_uctUserSys", "uctUserSys.w_sysNo":defSysEname};
        $.getJSON(common_list_url, dataP, function (myData) {
            count = myData.total;
            if(count==0){
                $("#home-user-tips").show();
            }else{
                $("#home-user-tips").hide();
            }
        });
        return count;
    }

    /**
    function showManagerUserTips() {
        var dataP = {"modelTypes": "s_uctUser", "uctUser.w_sysEname":defSysEname,"uctUser.w_userType":"manager"};
        $.getJSON(common_list_url, dataP, function (myData) {
            console.log('manager-user',myData);
            var count = myData.total;
            if(count==0){
                $("#home-user-tips").show();
            }else{
                $("#home-user-tips").hide();
            }
        });
    }
**/
    //初始化柱状图option
    function getOptionZhu(objMap) {
        var option = {
            title: {
                show: false
            },
            tooltip: {
                show: true,
                trigger: 'axis',
                axisPointer: {
                    lineStyle: {color: "#666"}
                }
            },
            toolbox: {
                show: false
            },
            calculable: true,
            grid: {
                x: 50,
                y: 30,
                x2: 30,
                y2: 30,
                borderWidth: 1
            },
            xAxis: [
                {
                    type: 'category',
                    show: true,
                    data: objMap[2],
                    splitLine: {show: false},//去除网格线
                    splitArea: {show: false}//保留网格区域
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    show: true,
                    splitLine: {show: false},//去除网格线
                    splitArea: {show: false}//保留网格区域
                }
            ],
            series: [
                {
                    name: objMap[0],
                    type: 'bar',
                    itemStyle: {
                        normal: {
                            color: function (params) {
                                // build a color map as your need.
                                var colorList = [
                                    '#404040','#dd4b39', '#337ab7', '#00a65a', '#ff4500', '#E87C25', '#27727B',
                                    '#FE8463', '#783FGD','A0522D'
                                ];
                                return colorList[params.dataIndex]
                            },
                            label: {
                                show: true,
                                position: 'top',
                                formatter: '{b}\n{c}'
                            }
                        }
                    },
                    data: objMap[3]
                }
            ]

        };
        return option;
    }

    function initCache() {
        $.ajax({
            type: 'get',
            url: "${ctx}/sendPage/initCache",
            async: false,
            dataType: "json",
            success: function (myData) {
                layer.alert(myData.msg);
            }
        });
    }

    function checkInitDataSource() {
        if(strUtil.isNull(defSysEname)){
            return;
        }
        $.ajax({ type:'get', url:common_list_url,dataType:'json',
            data:{'pageName':'datasource-list','formName':'searchForm','tRpcDatasource.w_sysEname':defSysEname},
                success: function(myData){
                    if(myData.total==0){
                        if(window.location.host.indexOf("portal.iussoft.com")>-1){
                            //添加测试数据源。
                            mytools.addTestDatasource("${database_type}",defSysEname);
                        }else{
                            layer.confirm('您还未配置数据源，是否配置默认的数据源！', {closeBtn: 0,btn: ['是','否，我自己设置']},
                                function(){
                                    //添加测试数据源。
                                    mytools.addTestDatasource("${database_type}",defSysEname);
                                }, function(){
                                    mytools.pjax("${page_admin}/project/datasource-list");
                                });
                        }
                    }
                }
        });

        initGuideIntroJs();
    }

    //判断是否第一次进入，启用步骤引导提示
    function initGuideIntroJs() {
        if(strUtil.isNull(strUtil.getLocalStorage("_iussoft_intro_project_index"))){
            strUtil.setLocalStorage("_iussoft_intro_project_index","T");
            showGuideIntroJs();
        }
    }

    //跳转后台管理中心
    function toManagementBack() {
        window.open("${ctx}/sendPage/"+defSysEname+"/admin/index");
    }
    function toMenuUrl(menuUrl) {
        mytools.pjax("${page_admin}/project/"+menuUrl);
    }
</script>


